#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#if HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif


#include "utils.h"

int run_external(int argc, char* args[])
{
  pid_t pid;
  int status, ret , wpid; 
  
  switch (pid = fork())
    {
    case -1: /*Error wit create chaild process*/
      myperror("fork()");
      break;
    case 0: /*Chaild process starts there */
      ret = execvp(args[0],args);
      myperror(args[0]);
      exit(ret);
      break;
    default: /*Parents proces continue there */
      wpid = wait(&status);
      break;
    };
  return WEXITSTATUS(status);
  
}
